package com.greensam.pixelengine.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author Ma Chengrui
 * @since 2025/10/30 14:15
 */
@Configuration
public class EventConfig {

    /**
     * 事件总线用来执行侦听器回调的线程池执行器
     */
    @Bean
    public ThreadPoolExecutor threadPoolExecutor() {
        int core = Math.max(2, Runtime.getRuntime().availableProcessors());
        return new ThreadPoolExecutor(core,
                core * 2,
                60,
                TimeUnit.SECONDS,
                new LinkedBlockingDeque<>(100));
    }

}
